<template>
	<view>
		<form @submit="pay">
			<view class="uni-title uni-common-mt uni-common-pl">请选择充值方式</view>
			<view class="uni-list">
				<radio-group @change="radioChange">
					<label class="uni-list-cell uni-list-cell-pd">
						<view>
							<radio name="payment" value="1" checked="" />
						</view>
						<view>支付宝</view>
					</label>
					<label class="uni-list-cell uni-list-cell-pd">
						<view>
							<radio name="payment" value="2" />
						</view>
						<view>微信</view>
					</label>
				</radio-group>
			</view>
			
			<view class="uni-form-item uni-column">
				<view class="title"><text class="uni-form-item__title">充值金额</text></view>
				<view class="uni-input-wrapper">
					<input name="amount" class="uni-input" v-model="formData.amount" type="number" maxlength="5" placeholder="请输入金额"/>
				</view>
			</view>
			
			<button type="primary" form-type="submit">确定</button>
		</form>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				formData: {
					payment: 1,
					amount: ''
				}
			};
		},
		methods: {
			radioChange(e) {
				this.formData.payment = e.detail.value;
			},
			pay(e) {
				let {payment, amount} = this.formData
				if(!payment || !amount) {
					uni.showToast({
						title: '请输入付款金额',
						icon: 'none',
						duration: 800
					})
					return
				}
				console.log(1);
				return
				uni.request({
				    url: this.$host + '/login',
				    data: {
						'mobile': mobile,
						'captcha': captcha
				    },
					method: 'POST',
				    success: (res) => {
						console.log(res.data);
						if (res.data.code) {
							uni.showToast({
								title: '登录成功',
								icon: "none",
								duration: 800
							})
							return;
						}
						
						// 登录成功跳转到我的
						uni.showToast({
							title: '登录成功',
							icon: "none",
							duration: 800
						})

				    }
				});
			},
		}
	}
</script>

<style lang="scss">
	.uni-list-cell {
		justify-content: flex-start
	}
</style>
